<template>
  <div class="num">
    <div class="sub" @click="subCount">-</div>
    <div class="tt">{{ count }}</div>
    <div class="add" @click="addCount">+</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      goodCount: 1,
    };
  },
  props: {
    count: {
      type: Number,
    },
    ids: {
      type: Number,
    },
  },
  
  methods: {
    // 减少数量
    subCount() {
        this.goodCount = this.count
      this.goodCount--
      if(this.goodCount <= 1){
        this.goodCount = 1
      }
    
      this.$emit("share-newCount", { count: this.goodCount, id: this.ids });
    },
    // 增加数量
    addCount() {
        this.goodCount = this.count
      this.goodCount++;
      this.$emit("share-newCount", { count: this.goodCount, id: this.ids });
    },

   
    
  },
};
</script>

<style lang="scss" scoped>
.num {
  height: 22px;
  line-height: 22px;
  border: 1px solid #a4a4a4;
  color: #a4a4a4;
  font-size: 14px;
  text-align: center;
  display: flex;
  .sub,
  .add {
    height: 100%;
    width: 33px;
  }
  .tt {
    border-right: 1px solid #a4a4a4;
    border-left: 1px solid #a4a4a4;
    height: 100%;
    width: 31px;
    color: #282828;
  }
}
</style>

